package tools.ppms;


import org.apache.commons.codec.binary.Base64;
import java.io.UnsupportedEncodingException;
import java.util.*;

/**
 * piao
 */
public class StringUtil {
    static byte[] key = {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab,
            (byte) 0xcd, (byte) 0xef, (byte) 0xfe, (byte) 0xdc,
            (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10};

    /**
     * @param str
     * @return 判断是否为空
     */
    public static boolean isNotEmpty(String... strings) {
        for (String str : strings) {
            if (str == null || str.trim().length() < 1) {
                return false;
            }
        }
        return true;
    }
    /**
     * map大写转小写
     *
     * @param map
     * @return
     */
    public static Map transMap(Map<String, Object> map) {
        Map newMap = new HashMap();
        for (String s : map.keySet()) {
            newMap.put(s.toLowerCase(), map.get(s));
        }
        return newMap;
    }

    /**
     * List大写转小写
     *
     * @return
     */
    public static List transList(List list) {
        List l = new ArrayList();
        int listSize = list.size();
        for (int i = 0; i < listSize; i++) {
            l.add(transMap((Map<String, Object>) list.get(i)));
        }
        return l;
    }
    public static boolean isNumber(String str){
        String reg = "^[0-9]+(.[0-9]+)?$";
        return str.matches(reg);
    }

    public static String jM(String obj) {
        byte[] b = SMS4.encodeSMS4(obj, key);
        return Base64.encodeBase64String(b);
    }

    public static String decode(String a) throws UnsupportedEncodingException {
        byte[] arr = Base64.decodeBase64(a);
        byte[] b = SMS4.decodeSMS4(arr, key);
        return new String(b, "gbk");
    }

    public static void main(String[] args) {
        System.out.println(StringUtil.jM(""));
    }


}


